package com.example.memo1.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.TextView;

import com.example.memo1.R;
import com.example.memo1.bean.Record;

import java.util.List;

public class RecordAdapter extends ArrayAdapter<Record> {

    private List<Record> items;

    public RecordAdapter( Context context, List<Record> items) {
        super(context, R.layout.manage_list,items);
        this.items=items;
    }
    @Override
    public View getView(int position, View converView, ViewGroup parent){
        if(converView==null){
            LayoutInflater inflater=LayoutInflater.from(getContext());
            converView=inflater.inflate(R.layout.manage_list,parent,false);
        }
        TextView title=converView.findViewById(R.id.title);
        TextView con=converView.findViewById(R.id.con);
        TextView time=converView.findViewById(R.id.time);

        Record res=items.get(position);
        title.setText(res.getTitle());
        con.setText(res.getCon());
        time.setText(res.getTime());


        return converView;

    }
    public void setRecordList(List<Record> recordList) {
        items.clear();
        items.addAll(recordList);
        notifyDataSetChanged(); // 通知列表视图进行更新
    }


}
